<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<script type="text/javascript">
	$(function() {
		var m = $("#pmode").val();
		$("#mode").val(m);
		if(m==1){
			 $("#dsrw").show();
			 $("#xhrw").hide();
			 $("#dsxh").hide();
			 $("#shijian").hide();
		 };
		 if(m==2){
			 $("#dsrw").hide();
			 $("#xhrw").show();
			 $("#dsxh").hide();
			 $("#shijian").show();
		 };
		 if(m==3){
			 $("#dsrw").hide();
			 $("#xhrw").hide();
			 $("#dsxh").show();
			 $("#shijian").show();
		 };
		 
		var pd = $("#pday").val();
		if(pd!=null&&pd!=""){
			//获取所有IUPUT为day的控件集合  
            var col = $("input[name='day']");  
            var list = pd.split(',');//把数据给拆分并放到list里面 
            for (var i = 0; i < col.length; i++) {
            	 for (var j = 0; j <= list.length; j++){
            		 if (col[i].value == list[j])//比较是否内容相等，如果一致就在界面上打上对勾  
                     {  
                         col[i].checked = true;//是combox选中，打上对勾  

                     }
            	 }
            }
		}
		var pw = $("#pweekday").val();
		if(pw!=null&&pw!=""){
			//获取所有IUPUT为day的控件集合  
            var col = $("input[name='weekday']");  
            var list = pw.split(',');//把数据给拆分并放到list里面 
            for (var i = 0; i < col.length; i++) {
            	 for (var j = 0; j <= list.length; j++){
            		 if (col[i].value == list[j])//比较是否内容相等，如果一致就在界面上打上对勾  
                     {  
                         col[i].checked = true;//是combox选中，打上对勾  

                     }
            	 }
            }
		}
		var ph = $("#phour").val();
		if(ph!=null&&ph!=""){
			//获取所有IUPUT为day的控件集合  
            var col = $("input[name='hour']");  
            var list = ph.split(',');//把数据给拆分并放到list里面 
            for (var i = 0; i < col.length; i++) {
            	 for (var j = 0; j <= list.length; j++){
            		 if (col[i].value == list[j])//比较是否内容相等，如果一致就在界面上打上对勾  
                     {  
                         col[i].checked = true;//是combox选中，打上对勾  

                     }
            	 }
            }
		}
		var pm = $("#pminute").val();
		if(pm!=null&&pm!=""){
			//获取所有IUPUT为day的控件集合  
            var col = $("input[name='minute']");  
            var list = ph.split(',');//把数据给拆分并放到list里面 
            for (var i = 0; i < col.length; i++) {
            	 for (var j = 0; j <= list.length; j++){
            		 if (col[i].value == list[j])//比较是否内容相等，如果一致就在界面上打上对勾  
                     {  
                         col[i].checked = true;//是combox选中，打上对勾  

                     }
            	 }
            }
		}
		$('#planEditForm').form({
			url : '${pageContext.request.contextPath}/plan/edit',
			onSubmit : function() {
				progressLoad();
				var isValid = $(this).form('validate');
				if (!isValid) {
					progressClose();
				}
				return isValid;
			},
			success : function(result) {
				progressClose();
				result = $.parseJSON(result);
				if (result.success) {
					parent.$.modalDialog.openner_dataGrid.datagrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_dataGrid这个对象，是因为plan.jsp页面预定义好了
					parent.$.modalDialog.handler.dialog('close');
				} else {
					parent.$.messager.alert('错误', result.msg, 'error');
				}
			}
		});
		$('#mode').combobox({
			onChange : function(){
			 var mode = $("input[name='mode']").val();
			 if(mode==1){
				 $("#dsrw").show();
				 $("#xhrw").hide();
				 $("#dsxh").hide();
				 $("#shijian").hide();
			 };
			 if(mode==2){
				 $("#dsrw").hide();
				 $("#xhrw").show();
				 $("#dsxh").hide();
				 $("#shijian").show();
			 };
			 if(mode==3){
				 $("#dsrw").hide();
				 $("#xhrw").hide();
				 $("#dsxh").show();
				 $("#shijian").show();
			 };
			}
		});  
	});
</script>
<style>
.grid td {
border: 1px solid #8DB2E3;
padding: 5px 0px 5px 5px;
}
</style>
<div class="easyui-layout" data-options="fit:true,border:false" >
	<div data-options="region:'center',border:false" title="" style="overflow: hidden;padding: 3px;" >
		<form id="planEditForm" method="post">
			<table class="grid">
				<tr>
					<td style="width:70px;">
					<input type="hidden" name="id" id="pid" value="${plan.id}"/>
					<input type="hidden" id="pmode" value="${plan.mode}"/>
					<input type="hidden" id="pday" value="${plan.day}"/>
					<input type="hidden" id="pweekday" value="${plan.weekday}"/>
					<input type="hidden" id="phour" value="${plan.hour}"/>
					<input type="hidden" id="pminute" value="${plan.minute}"/>
					任务名称:</td>
					<td style="width:180px;"><input name="name" type="text" placeholder="请输入任务名称" class="easyui-validatebox span2" data-options="required:true" value="${plan.name}"></td>
					<td style="width:70px;">Controller</td>
					<td><input name="controller" type="text" placeholder="" class="easyui-validatebox span2" data-options="required:true" value="${plan.controller}"></td>
					
				</tr>
				<tr>
					<td>Action</td>
					<td><input name="action" type="text" placeholder="" class="easyui-validatebox span2" data-options="required:true" value="${plan.action}"></td>
					<td>模式:</td>
					<td><select id="mode" name="mode" class="easyui-combobox" data-options="width:140,height:29,editable:false,panelHeight:'auto'">
							<option value="1">定时运行</option>
							<option value="2">循环运行</option>
							<option value="3">定时循环运行</option>
					</select></td>
				</tr>
			</table>
			<table id="dsrw" style="border-top:0;" class="grid">
				<tr>
					<td style="width:70px;border-top:0;">运行时间:</td>
					<td style="border-top:0;" colspan="3">
						<input name="time" type="text" placeholder="" class="easyui-datetimebox" data-options="width:160" value="${plan.time}">
					</td>
				</tr>
			</table>
			<table id="xhrw" style="display:none;border-top:0;" class="grid">
				<tr>
					<td style="width:70px;border-top:0;">间隔(分钟):</td>
					<td style="width:180px;border-top:0;">
						<input name="pinterval" type="text" placeholder="" class="easyui-validatebox span2" data-options="" value="${plan.pinterval}">
					</td>
					<td style="width:70px;border-top:0;">最多次数:</td>
					<td style="border-top:0;">
						<input name="times" type="text" placeholder="" class="easyui-validatebox span2" data-options="" value="${plan.times}">
					</td>
				</tr>
				
			</table>
			<table id="dsxh" style="display:none;border-top:0;" class="grid">
				<tr>
					<td style="width:70px;border-top:0;">按月设置:<br/>(全选/取消)</td>
					<td style="border-top:0;" colspan="3">
						<label><input name="day" type="checkbox" value="01" />01</label> 
						<label><input name="day" type="checkbox" value="02" />02</label> 
						<label><input name="day" type="checkbox" value="03" />03</label> 
						<label><input name="day" type="checkbox" value="04" />04</label>
						<label><input name="day" type="checkbox" value="05" />05</label>
						<label><input name="day" type="checkbox" value="06" />06</label>
						<label><input name="day" type="checkbox" value="07" />07</label>
						<label><input name="day" type="checkbox" value="08" />08</label>
						<label><input name="day" type="checkbox" value="09" />09</label>
						<label><input name="day" type="checkbox" value="10" />10</label>
						<label><input name="day" type="checkbox" value="11" />11</label><br/>
						<label><input name="day" type="checkbox" value="12" />12</label>
						<label><input name="day" type="checkbox" value="13" />13</label>
						<label><input name="day" type="checkbox" value="14" />14</label>
						<label><input name="day" type="checkbox" value="15" />15</label>
						<label><input name="day" type="checkbox" value="16" />16</label>
						<label><input name="day" type="checkbox" value="17" />17</label>
						<label><input name="day" type="checkbox" value="18" />18</label>
						<label><input name="day" type="checkbox" value="19" />19</label>
						<label><input name="day" type="checkbox" value="20" />20</label>
						<label><input name="day" type="checkbox" value="21" />21</label>
						<label><input name="day" type="checkbox" value="22" />22</label><br/>
						<label><input name="day" type="checkbox" value="23" />23</label>
						<label><input name="day" type="checkbox" value="24" />24</label>
						<label><input name="day" type="checkbox" value="25" />25</label>
						<label><input name="day" type="checkbox" value="26" />26</label>
						<label><input name="day" type="checkbox" value="27" />27</label>
						<label><input name="day" type="checkbox" value="28" />28</label>
						<label><input name="day" type="checkbox" value="29" />29</label>
						<label><input name="day" type="checkbox" value="30" />30</label>
						<label><input name="day" type="checkbox" value="31" />31</label>
					</td>
				</tr>
				<tr>
					<td style="width:70px;border-top:0;">按周设置:<br/>(全选/取消)</td>
					<td style="border-top:0;" colspan="3">
						<label><input name="weekday" type="checkbox" value="1" />周一</label> 
						<label><input name="weekday" type="checkbox" value="2" />周二</label> 
						<label><input name="weekday" type="checkbox" value="3" />周三</label> 
						<label><input name="weekday" type="checkbox" value="4" />周四</label>
						<label><input name="weekday" type="checkbox" value="5" />周五</label>
						<label><input name="weekday" type="checkbox" value="6" />周六</label>
						<label><input name="weekday" type="checkbox" value="7" />周日</label>
					</td>
				</tr>
				<tr>
					<td style="width:70px;border-top:0;">运行时段:<br/>(全选/取消)</td>
					<td style="border-top:0;" colspan="3">
						<label><input name="hour" type="checkbox" value="00" />00</label> 
						<label><input name="hour" type="checkbox" value="01" />01</label> 
						<label><input name="hour" type="checkbox" value="02" />02</label> 
						<label><input name="hour" type="checkbox" value="03" />03</label> 
						<label><input name="hour" type="checkbox" value="04" />04</label>
						<label><input name="hour" type="checkbox" value="05" />05</label>
						<label><input name="hour" type="checkbox" value="06" />06</label>
						<label><input name="hour" type="checkbox" value="07" />07</label>
						<label><input name="hour" type="checkbox" value="08" />08</label>
						<label><input name="hour" type="checkbox" value="09" />09</label>
						<label><input name="hour" type="checkbox" value="10" />10</label>
						<label><input name="hour" type="checkbox" value="11" />11</label><br/>
						<label><input name="hour" type="checkbox" value="12" />12</label>
						<label><input name="hour" type="checkbox" value="13" />13</label>
						<label><input name="hour" type="checkbox" value="14" />14</label>
						<label><input name="hour" type="checkbox" value="15" />15</label>
						<label><input name="hour" type="checkbox" value="16" />16</label>
						<label><input name="hour" type="checkbox" value="17" />17</label>
						<label><input name="hour" type="checkbox" value="18" />18</label>
						<label><input name="hour" type="checkbox" value="19" />19</label>
						<label><input name="hour" type="checkbox" value="20" />20</label>
						<label><input name="hour" type="checkbox" value="21" />21</label>
						<label><input name="hour" type="checkbox" value="22" />22</label>
						<label><input name="hour" type="checkbox" value="23" />23</label>
					</td>
				</tr>
				<tr>
					<td style="width:70px;border-top:0;">运行分钟:<br/>(全选/取消)</td>
					<td style="border-top:0;" colspan="3">
						<label><input name="minute" type="checkbox" value="00" />00</label> 
						<label><input name="minute" type="checkbox" value="10" />10</label> 
						<label><input name="minute" type="checkbox" value="20" />20</label> 
						<label><input name="minute" type="checkbox" value="30" />30</label> 
						<label><input name="minute" type="checkbox" value="40" />40</label>
						<label><input name="minute" type="checkbox" value="50" />50</label>
					</td>
				</tr>
			</table>
			<table id="shijian" style="display:none;border-top:0;" class="grid">
				<tr>
					<td style="width:70px;border-top:0;">开始时间:</td>
					<td style="width:180px;border-top:0;">
						<input name="starttime" type="text" placeholder="" class="easyui-datetimebox" data-options="width:160" value="${plan.starttime}">
					</td>
					<td style="width:70px;border-top:0;">结束时间:</td>
					<td style="border-top:0;">
						<input name="endtime" type="text" placeholder="" class="easyui-datetimebox" data-options="width:160" value="${plan.endtime}">
					</td>
				</tr>
			</table>
		</form>
	</div>
</div>